package com.xxl.job.executor.util;

import org.apache.kafka.clients.producer.KafkaProducer;

import java.util.Properties;

public class KafkaUtil {
    private static KafkaProducer producer;

    /**
     * 获取kafka对象
     * @return
     */
    public static KafkaProducer getKafkaProducer(String kafkaBS,String kafkaKS,String kafkaVS){
        if(null == producer){
            Properties kafkaProperties = new Properties();
            kafkaProperties.put("bootstrap.servers", kafkaBS);
            kafkaProperties.put("key.serializer", kafkaKS);
            kafkaProperties.put("value.serializer", kafkaVS);
            KafkaProducer producer = new KafkaProducer(kafkaProperties);
            KafkaUtil.producer = producer;
        }
        return producer;
    }

}
